<style>
    #random:hover{
        background:#333333;
    }
</style>
<div class="panel panel-default panel-intro">
    {:build_heading()}

    <div class="panel-body">
        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div id="toolbar" class="toolbar">
                        {:build_toolbar($btns)}
                        <a class="btn btn-primary " id="random" >批量投放</a>
                        <a class="btn btn-primary " id="random2" >生成新的编码</a>
                        <div class="dropdown btn-group {:$auth->check('bottle/random/multi')?'':'hide'}">
                            <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
                            <ul class="dropdown-menu text-left" role="menu">
                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li>
                                <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>
                            </ul>
                        </div>
                    </div>
                    <table id="table" class="table table-striped table-bordered table-hover" 
                           data-operate-del="{:$auth->check('bottle/random/del')}"
                           width="100%">
                    </table>
                </div>
            </div>

        </div>
    </div>
</div>
<script src="__PUBLIC__assets/js/jquery-1.11.3.min.js"></script>
<script>
    $(function () {
        $('#random').click(function () {
                var id=[];
            $('.selected td:nth-child(2)').each(function(){
               id.push($(this).text());
            });
            $.ajax({
                url: "{:url('bottle.random/update')}",
                type:'POST',
                data: {'id': id},
                success: function (res) {
                    layer.alert(res.msg, function () {
                        window.location.reload();
                    });
                }
            });
        });
        $('#random2').click(function () {
            $.ajax({
                url: "{:url('bottle.random/testAddRandomNum')}",
                success: function (res) {
                    layer.alert(res.msg, function () {
                        window.location.reload();
                    });
                }
            });
        });
    })
</script>